package com.bgds.sys.api.project;


import com.bgds.sys.api.project.request.ProjectRequest;
import com.bgds.sys.api.project.service.ProjectItemService;
import com.bgds.sys.common.pagevo.Result;
import com.bgds.sys.common.utils.ResultUtil;
import com.bgds.sys.module.entity.project.ProjectItem;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;


/**
 * 项目管理
 *
 * @author chenchao
 * @date 2021/9/14
 */
@RestController
@RequestMapping("/project/item")
public class ProjectItemController {


    @Resource
    private ProjectItemService projectItemService;

    /**
     * 功能描述
     *
     * @param request
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.bgds.sys.api.project.response.ProjectItemResponse>
     * @author chenchao
     * @date 2021/9/15
     */

    @GetMapping
    public Result pageList(ProjectRequest request) {
        return new ResultUtil().setData(projectItemService.pageList(request));
    }


    /**
     * 功能描述
     *
     * @param id
     * @return com.bgds.sys.api.project.response.ProjectItemResponse
     * @author chenchao
     * @date 2021/9/15
     */
    @GetMapping("/{id}")
    public Result getProject(@PathVariable("id") Long id) {
        return new ResultUtil().setData(projectItemService.getProjectItem(id));
    }

    /**
     * 功能描述
     *
     * @param item
     * @return com.bgds.sys.common.pagevo.Result
     * @author chenchao
     * @date 2021/9/15
     */
    @PutMapping
    public Result addProject(@RequestBody ProjectItem item) {
        projectItemService.add(item);
        return new ResultUtil<>().success();

    }


    /**
     * 导出
     *
     * @param ids
     * @return void
     * @author chenchao
     * @date 2021/9/15
     */
    @GetMapping("/export")
    public void export(HttpServletResponse response, String ids){
        projectItemService.export(response,ids);
    }

    /**
     * 统计
     *
     * @param
     * @return java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
     * @author chenchao
     * @date 2021/9/19
     */
    @GetMapping("/statistics")
    public Result statistics(){
        return new ResultUtil().setData(projectItemService.statistics());
    }
}
